package com.android.djlmapp.adapter.my;
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckedTextView;
import android.widget.RadioButton;
import android.widget.TextView;
import com.android.djlmapp.R;

import java.util.List;

public class ShaiXuanAdapter extends BaseAdapter {
    private List bleNameList;
    private Activity mContext;
    private int selectedIndex;

    public ShaiXuanAdapter(Activity mContext, List bleNameList, int sel) {
        this.bleNameList = bleNameList;
        this.mContext = mContext;
        this.selectedIndex = sel;
    }

    public void setSelectedIndex(int index) {
        selectedIndex = index;
    }
    @Override
    public int getCount() {
        return bleNameList.size() > 0 ? bleNameList.size() : 0;
    }

    @Override
    public String getItem(int position) {
        return (String) bleNameList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        View view = View.inflate(mContext, R.layout.duizhang_popup_item, null);
        CheckedTextView tv_ble = (CheckedTextView) view.findViewById(R.id.sx_all);
        tv_ble.setText(getItem(position));
        if (selectedIndex == position) {
            tv_ble.setChecked(true);
        } else {
            tv_ble.setChecked(false);
        }
        return view;
    }


}